{% extends "base.html" %}
{% load wagtailcore_tags %}

{% block content %}

    {% if request.GET.tag|length %}
        <h4>Showing pages tagged "{{ request.GET.tag }}"</h4>
    {% endif %}

    {% for blogpage in blogpages %}

          <p>
              <strong><a href="{% pageurl blogpage %}">{{ blogpage.title }}</a></strong><br />
              <small>Revised: {{ blogpage.latest_revision_created_at }}</small><br />
              {% if blogpage.author %}
                <p>By {{ blogpage.author.profile }}</p>
              {% endif %}
          </p>

    {% empty %}
        No pages found with that tag.
    {% endfor %}


    <nav aria-label="Page navigation">
        <ul class="pagination justify-content-center">
            {% if blogpages.has_previous %}
                <li class="page-item">
                    <a class="page-link" href="?tag={{ tag }}&page={{ blogpages.previous_page_number }}">&laquo;</a>
                </li>
            {% endif %}
            {% for page_num in blogpages.paginator.page_range %}
                <li {% if page_num == blogpages.number %} class="active page-item"{% endif %}>
                    <a class="page-link" href="?tag={{ tag }}&page={{ page_num }}">{{ page_num }}</a>
                </li>
            {% endfor %}
            {% if blogpages.has_next %}
                <li class="page-item">
                    <a class="page-link" href="?tag={{ tag }}&page={{ blogpages.next_page_number }}">&raquo;</a>
                </li>
            {% endif %}
        </ul>
    </nav>

{% endblock %}